-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-38516][Table SQL/Gateway] Add config for read-only sql gateway #27118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
liuml07
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks like a useful feature for some use cases. Left some comment.
|
|
||
| if (isReadOnlyMode) { | ||
| throw new SqlExecutionException( | ||
| "SQL Gateway is in read-only mode. Modify operations are not allowed."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it's useful to show the modifyOperations in the error message in case it's unclear to users which are actually violating the read-only mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liuml07 These modifyOperations arent tied to a specific modify type i.e. INSERT, UPDATE, so this would require having to categorize them into a type. I would prefer to leave the error message generic also given that SQL is run line by line and is easy to determine which query failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liuml07 I can instead pass in the sql statement to callModifyOperations and log it there. Let me know what you think!
|
@flinkbot run azure |
https://issues.apache.org/jira/browse/FLINK-38516
What is the purpose of the change
The Flink SQL Gateway currently lacks native support for read-only mode to restrict ModifyOperations (e.g., INSERT, DELETE). This feature allows ad-hoc querying on shared session clusters without risk of data modification.
This pull request adds a a configuration parameter
sql-gateway.read-onlysuch that if enabled, it rejects SQL statements attempting to modify data or schema.Brief change log
Verifying this change
Submit a FlinkSQL modification query to a session cluster and check that executing the query throws an exception i.e.

Added tests:
testReadOnlyModeWithModificationOperations: Verifies single INSERT shows the specific SQL
testReadOnlyModeWithStatementSet: Verifies statement sets show the generic message
testReadOnlyModeWhenOperationInsertError: Verifies malformed SQL fails at parse time
Full stack trace:
Click to expand
Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation